/**
 * @file
 */
#ifndef WII_GI_C_FONT_H
#define WII_GI_C_FONT_H

#include <wchar.h>

#include "FreeTypeGX.h"
#include "e_Status.h"
#include "c_Mutex.h"

namespace wiigi
{
   /**
    * small class to wrap around FreeTypeGX
    */
   class c_TT_Font
   {
      public:
         
         c_TT_Font( void );
         
         /**
          * destructor
          */
         ~c_TT_Font( void );
         
         /**
          * loads specified TTF file
          */
         e_Status loadTTF( 
            const char* FileName,
            u32         PointSize,
            bool        CacheAll = false
            );
         
         /**
          * draws text to screen
          */   
         uint16_t drawFixedText( 
            uint16_t x, 
            uint16_t y, 
            wchar_t const *text);
         
         void setColour( GXColor& Colour )
         {
            m_Colour = Colour;
         }
         
         void setStyle( uint16_t Style )
         {
            m_Style = Style;
         }
         
         void drawText( 
            uint16_t x, 
            uint16_t y, 
            const char * FormatMsg,
            ...
         );
         
         
      private:
            
            void reset( void )
            {
               if( m_freeTypeGX )
               {
                  delete m_freeTypeGX;
                  m_freeTypeGX = 0;
               }
                  
               if( m_TTF_Buffer )
               {
                  delete m_TTF_Buffer;
                  m_TTF_Buffer = 0;
               }
               
               return;
            }
      
      private:
         
         u8*         m_TTF_Buffer;
         FreeTypeGX* m_freeTypeGX;
         GXColor     m_Colour;
         uint16_t    m_Style;
         
         
         c_Mutex          m_StringBufferMutex;
         static const u32 d_StringBufferSize = 256;
         static char       m_StringBuffer[];
         static wchar_t    m_StringWBuffer[];
         
         
   };
   
}

#endif //WII_GI_C_FONT_H
